<?php
/*
 * OrangeHRM is a comprehensive Human Resource Management (HRM) System that captures
 * all the essential functionalities required for any enterprise.
 * Copyright (C) 2006 OrangeHRM Inc., http://www.orangehrm.com
 *
 * OrangeHRM is free software; you can redistribute it and/or modify it under the terms of
 * the GNU General Public License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * OrangeHRM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with this program;
 * if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA  02110-1301, USA
 */
$styleSheet = "orange";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<script type="text/javascript" src="../../scripts/archive.js"></script>
<script type="text/javascript" src="../../scripts/time.js"></script>

<link href="../../themes/<?php echo $styleSheet;?>/css/leave.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../../themes/<?php echo $styleSheet;?>/scripts/style.js"></script>
<link href="../../themes/<?php echo $styleSheet;?>/css/style.css" rel="stylesheet" type="text/css"/>
<!--[if lte IE 6]>
<link href="../../themes/<?php echo $styleSheet; ?>/css/IE6_style.css" rel="stylesheet" type="text/css"/>
<![endif]-->
<!--[if IE]>
<link href="../../themes/<?php echo $styleSheet; ?>/css/IE_style.css" rel="stylesheet" type="text/css"/>
<![endif]-->
<script>

</script>
</head>
<body class="yui-skin-sam">

<div class="outerbox">
    <div class="outerbox"><div class="top"><div class="left"></div><div class="right"></div><div class="middle"></div></div><div class="maincontent">
        <div class="mainHeading"><h2><font color="#ff0000"></font> 审核</h2></div>


   <div class="actionbar">
    <br class="clear">
    </div>
    <br class="clear">
    <form id="frmListOfShifts" name="frmListOfShifts" method="post" action="?ctrl=power&action=editSave">
    	<input type="hidden" name="id" value="<?php echo $records['info']['Id'];?>"/>
    	<table >
	    	<tbody>
	    		<tr>
			    	<td>
			    	 权限组名称:
			    	</td>
			    	<td>
			    	 <input type="text"  name="roleName" value="<?php echo $records['info']['Name']?> " />
			    	</td>
		    	</tr>
	    		<tr>
			    	<td>
			    	 操作:
			    	</td>
			    	<td>
			    	 <input type="submit"  value="保存" />
			    	</td>
		    	</tr>
	    	</tbody>
    	</table>
           <?php
                //第一层
       		    foreach ($records['configs'] as $kr=>$vr) { ?>
       		    	<div >
            		<br/>&nbsp;&nbsp;&nbsp;<input type="checkbox"  name="power[]"  value="<?php echo $vr['num']?>" id="top_<?php echo $vr['num'];?>"   onclick="selectOne(this,<?php echo $vr['num'];?>)"  ><?php echo $vr['name'];?>
            			<?php if(isset($vr['subMenu']) && !empty($vr['subMenu'])) { //第二层
            				foreach ($vr['subMenu'] as $kvr=>$vvr) {
            				?>
            				<div >
            				<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;--<input type="checkbox"   id="top_<?php echo $kvr?>"  name="power[]" value="<?php echo $kvr?>"  onclick="selectOne(this,<?php echo $kvr;?>)" ><?php echo $vvr['name'];?>
            						<?php if (isset($vvr['operate'])) {
		            						foreach ($vvr['operate'] as $vok=>$vov) { ?>
						            				<div >
						            				<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;--<input type="checkbox"   id="top_<?php echo $kvr."_".$vok?>"  name="power[]" value="<?php echo $kvr.'_'.$vok;?>"  onclick="selectOne(this,<?php echo $kvr;?>)" ><?php echo $vov;?>
						            				</div> 
		            			<?php }
            								}?>
            				<?php if(isset($vvr['subMenu']) && !empty($vvr['subMenu'])) {  //第三层
		            				foreach ($vvr['subMenu'] as $kvvr=>$vvvr) {
		            					 
		            				?>
		            				    <div>
		            					<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;--<input type="checkbox"  name="power[]" id="top_<?php echo $kvvr;?>"  value="<?php echo $kvvr?>" onclick="selectOne(this,<?php echo $kvvr;?>)"><?php echo $vvvr['name'];?>
            						<?php if (isset($vvvr['operate'])) {  //第四层
		            						foreach ($vvvr['operate'] as $vok=>$vov) { ?>
						            				<div >
						            				<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;--<input type="checkbox"   id="top_<?php echo $kvvr."_".$vok?>"  name="power[]" value="<?php echo $kvvr.'_'.$vok;?>"  onclick="selectOne(this,<?php echo $kvvr;?>)" ><?php echo $vov;?>
						            				</div> 
		            			<?php }
            								}?>
		            					</div>
		            		<?php
		            				 }
            					 } //第三层结束
            			  ?>
            			 </div>
            			<?php
            				 }
            			 } //第二层结束
            			 ?>
				</div>
            <?php } //第一层结束?>

      </form>
  </div><div class="bottom"><div class="left"></div><div class="right"></div><div class="middle"></div></div></div>
</div>


<script language="javascript" >
function selectOne(obj,id) {
	var bb=obj.checked;
	jQuery("#top_"+id).attr("checked",bb);
	jQuery(obj).parent().find("input[type=checkbox]").attr("checked",bb);
	while(id>100) {
		var iddd=parseInt(id/100);
		if(bb==false) {
			var isChildChecked=false;
			jQuery("#top_"+iddd).parent().children("div").find("input[type=checkbox]").each(function(){
         			if(this.checked==true) {
         				isChildChecked=true;
         			}
      			});
      		if(!isChildChecked) {
				jQuery("#top_"+iddd).attr("checked",bb);
      		}
		} else {
			jQuery("#top_"+iddd).attr("checked",bb);
		}
		id=iddd;
	}

}
function checkSome(obj) {
	for(var j in obj) {
		jQuery("#top_"+ obj[j]).attr("checked",true);
	}
}
var dd=<?php echo $records['info']['RightDetail'];?>;
checkSome(dd);
</script>
</body>
</html>
